home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 June / PCWorld_2007-06_cd.bin / v cisle / tclock / tclocklight-040702-3.exe / source / property / pagemisc.c < prev    next >
C/C++ Source or Header  |  2004-01-18  |  4KB  |  149 lines

  1. /*-------------------------------------------------------------
  2.   pagemisc.c : "Misc" page of properties
  3.   (C) Kazuto Sato 1997-2003
  4.   For the license, please read readme.txt.
  5.   
  6.   Written by Kazubon, Nanashi-san
  7. ---------------------------------------------------------------*/
  8.  
  9. #include "tcprop.h"
  10.  
  11. /* Globals */
  12.  
  13. BOOL CALLBACK PageMiscProc(HWND hDlg, UINT message,
  14.     WPARAM wParam, LPARAM lParam);
  15.  
  16. /* Statics */
  17.  
  18. static void SendPSChanged(HWND hDlg);
  19. static void OnInit(HWND hDlg);
  20. static void OnApply(HWND hDlg);
  21. static void OnBrowse(HWND hDlg);
  22.  
  23. static m_bInit = FALSE;
  24.  
  25. /*------------------------------------------------
  26.   dialog procedure
  27. --------------------------------------------------*/
  28. BOOL CALLBACK PageMiscProc(HWND hDlg, UINT message,
  29.     WPARAM wParam, LPARAM lParam)
  30. {
  31.     switch(message)
  32.     {
  33.         case WM_INITDIALOG:
  34.             OnInit(hDlg);
  35.             return TRUE;
  36.         case WM_COMMAND:
  37.         {
  38.             WORD id, code;
  39.             id = LOWORD(wParam); code = HIWORD(wParam);
  40.             switch (id)
  41.             {
  42.                 case IDC_NOCLOCK:
  43.                     g_bApplyClock = TRUE;
  44.                     SendPSChanged(hDlg);
  45.                     break;
  46.                 case IDC_MCIWAVE:
  47.                 case IDC_TASKBARRESTART:
  48.                     SendPSChanged(hDlg);
  49.                     break;
  50.                 case IDC_DELAYSTART:
  51.                     if(code == EN_CHANGE)
  52.                         SendPSChanged(hDlg);
  53.                     break;
  54.                 case IDC_BROWSEHELP:
  55.                     OnBrowse(hDlg);
  56.                     break;
  57.             }
  58.             return TRUE;
  59.         }
  60.         case WM_NOTIFY:
  61.             switch(((NMHDR *)lParam)->code)
  62.             {
  63.                 case PSN_APPLY: OnApply(hDlg); break;
  64.                 case PSN_HELP: MyHelp(GetParent(hDlg), "Misc"); break;
  65.             }
  66.             return TRUE;
  67.     }
  68.     return FALSE;
  69. }
  70.  
  71. /*------------------------------------------------
  72.   notify parent window to enable "Apply" button
  73. --------------------------------------------------*/
  74. void SendPSChanged(HWND hDlg)
  75. {
  76.     if(m_bInit)
  77.         SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)(hDlg), 0);
  78. }
  79.  
  80. /*------------------------------------------------
  81.   initialize
  82. --------------------------------------------------*/
  83. void OnInit(HWND hDlg)
  84. {
  85.     char s[MAX_PATH];
  86.     
  87.     // common/tclang.c
  88.     SetDialogLanguage(hDlg, "Misc", g_hfontDialog);
  89.     
  90.     CheckDlgButton(hDlg, IDC_NOCLOCK,
  91.         GetMyRegLong(NULL, "NoClock", FALSE));
  92.     
  93.     CheckDlgButton(hDlg, IDC_MCIWAVE,
  94.         GetMyRegLong(NULL, "MCIWave", FALSE));
  95.     
  96.     SetDlgItemInt(hDlg, IDC_DELAYSTART,
  97.         GetMyRegLong(NULL, "DelayStart", 0), FALSE);
  98.     
  99.     CheckDlgButton(hDlg, IDC_TASKBARRESTART,
  100.         GetMyRegLong(NULL, "TaskbarRestart", FALSE));
  101.     
  102.     GetMyRegStr(NULL, "HelpURL", s, MAX_PATH, "");
  103.     SetDlgItemText(hDlg, IDC_HELPURL, s);
  104.     
  105.     m_bInit = TRUE;
  106. }
  107.  
  108. /*------------------------------------------------
  109.   apply
  110. --------------------------------------------------*/
  111. void OnApply(HWND hDlg)
  112. {
  113.     char s[MAX_PATH];
  114.     
  115.     SetMyRegLong(NULL, "NoClock",
  116.         IsDlgButtonChecked(hDlg, IDC_NOCLOCK));
  117.     
  118.     SetMyRegLong(NULL, "MCIWave",
  119.         IsDlgButtonChecked(hDlg, IDC_MCIWAVE));
  120.     
  121.     SetMyRegLong(NULL, "DelayStart",
  122.         GetDlgItemInt(hDlg, IDC_DELAYSTART, NULL, FALSE));
  123.     
  124.     SetMyRegLong(NULL, "TaskbarRestart",
  125.         IsDlgButtonChecked(hDlg, IDC_TASKBARRESTART));
  126.     
  127.     GetDlgItemText(hDlg, IDC_HELPURL, s, MAX_PATH);
  128.     SetMyRegStr(NULL, "HelpURL", s);
  129. }
  130.  
  131. /*------------------------------------------------
  132.   clicked "..." button
  133. --------------------------------------------------*/
  134. void OnBrowse(HWND hDlg)
  135. {
  136.     char deffile[MAX_PATH], fname[MAX_PATH];
  137.     char *filter = "HTML\0*.html;*.htm\0\0";
  138.     
  139.     GetDlgItemText(hDlg, IDC_HELPURL, deffile, MAX_PATH);
  140.     
  141.     if(!SelectMyFile(g_hInst, hDlg, filter, 0, deffile, fname))
  142.         return;
  143.     
  144.     SetDlgItemText(hDlg, IDC_HELPURL, fname);
  145.     PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE);
  146.     SendPSChanged(hDlg);
  147. }
  148.  
  149.